<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<div id="one">
    <p>你好，我是测<i>我是i标签</i>试页</p>
</div>

</body>
<script>
    var jies = document.getElementById('one');
    console.log(jies);
    console.log(jies.textContent);//ie不支持,w3c标准
    console.log(jies.innerText);//原ie的,现在都支持
    console.log(jies.innerHTML);//都支持,但是不解析标签,得到的内容含有标签
    //封装函数,获取函数的文本----解决兼容问题
    function getText(ele) {
        if (ele.textContent == false) {
            return ele.textContent;
        }else {
            return ele.innerText;
        }
    }

    //封装函数,用来设置元素的文本
    function setText(ele,text) {
        if (typeof ele.textContent == 'string') {
            ele.textContent = text;
        } else {
            ele.innerText = text;
        }
    }
</script>
</html>